<?phpset_include_path('system'.PATH_SEPARATOR.'templates');

require_once('Template.php');
require_once('RedirectBrowserException.php');
require_once('DatabaseUtility.php');

$tmpl = new Template();$filename = "DataForExcelTable2.txt";

print $tmpl->build('page.tmpl');
print '<table border="1" style="width:200px; margin: -500px auto 0 auto;">';openDatabase();$file = fopen($filename, "r") or exit("Unable to open file!");$count = 0;$protein = "";while(!feof($file)){	$count ++;	$recordline = trim(fgets($file));	$records = explode("\t",$recordline);  	if(sizeof($records)!=2) {
		print "Wrong format or lack of information at Line ".$count."\n";continue;
	}	$nextprotein = trim($records[0]);$nextprotein = str_ireplace("+","",$nextprotein);
	if(strcmp($nextprotein,"")!=0) {
		$protein = $nextprotein;
	}
	$oriseq = trim($records[1]);	$searchseq = substr($oriseq, 2, strlen($oriseq)-4);	$seq = substr($oriseq, 2, strlen($oriseq)-4);	$searchseq=str_ireplace("(pS)","S#",$searchseq);	$searchseq=str_ireplace("(pT)","T#",$searchseq);	$searchseq=str_ireplace("(pY)","Y#",$searchseq);	$seq=str_ireplace("(pS)","S%23",$seq);	$seq=str_ireplace("(pT)","T%23",$seq);	$seq=str_ireplace("(pY)","Y%23",$seq);	$sql_search_protein = "SELECT * FROM idMapping WHERE otherID = '$protein'";	$proteinsearchresult = mysql_query($sql_search_protein);	$rownumprotein = mysql_num_rows($proteinsearchresult);	$proteinsql = "";
		if($rownumprotein>0) {		$proteinresultrow = mysql_fetch_array($proteinsearchresult);		$proteinid = $proteinresultrow["p3dbId"]; 		$proteinlink = "/protein.php?id=$proteinid&ref=16";		$proteinsql = " and protein = $proteinid"; 	} else {		$proteinlink="";	}
		$sql_search_peptide = "SELECT * FROM peptide WHERE phosphoSequence = '$searchseq' $proteinsql";	$peptidesearchresult = mysql_query($sql_search_peptide);	$rownumpeptide = mysql_num_rows($peptidesearchresult);	if($rownumpeptide > 0) {		$peptideresultrow = mysql_fetch_array($peptidesearchresult);		$proid = $peptideresultrow["protein"];		$location = $peptideresultrow["location"];		$peptidelink = "/peptide.php?pnrseq=$seq&pro=$proid&loc=$location&ref=16&select=Select";	} else {		$peptidelink = "";	}
	if(strcmp($proteinlink,"")!=0 && strcmp($peptidelink,"")!=0) {
		print "<tr>
		<td><a href='$proteinlink'>$protein</a></td>
		<td><a href='$peptidelink'>$oriseq</a></td>
		</tr>";
	}}fclose($file);closeDatabase();

print '</table>';?>